<?php


namespace App\Services\Result\Type;


use App\Models\Examination;
use Illuminate\Http\Request;
use App\Models\StudentResult;
use App\Services\Result\BaseResult;

class ListResult extends BaseResult
{
    public function show(Examination $testResult, Request $request)
    {
        parent::show($testResult,$request);
        $data = StudentResult::query()
            ->select('id', 'user_id', 'name', 'username', 'fraction', 'all_num', 'success_num', 'error_num', 'already_num', 'submit_type', 'join_time', 'test_list_id')
            ->where('examination_id', $this->examination_id)
            ->paginate($this->pageLimit());

        foreach ($data as $k => $item) {
            $data[$k]['not'] = $item['all_num'] - $item['already_num'];
        }

        return $data;
    }
}
